package code29;

import java.util.Scanner;

public class OneArrayForAll {
    public static void main(String[] args) {
        // 每门成绩对应的索引
        int YuWen = 0;
        int ShuXue = 1;
        int WaiYu = 2;
        int WuLi = 3;
        int HuaXue = 4;
        int ShengWu = 5;


        // 每门课的名字
        String[] names = new String[6];
        names[YuWen] = "语文";
        names[ShuXue] = "数学";
        names[WaiYu] = "外语";
        names[WuLi] = "物理";
        names[HuaXue] = "化学";
        names[ShengWu] = "生物";

        Scanner in = new Scanner(System.in);

        System.out.println("请问要保存几年的成绩？");

        int yearToStore = in.nextInt();

        double[][] scores = new double[yearToStore][names.length];

        for (int i = 0; i < yearToStore; i++) {
            for (int j = 0; j < names.length; j++) {
                scores[i][j] = 80 + Math.random() * 20;
            }
        }
        System.out.println("请问你要查看第几年的成绩？");

        int year = in.nextInt() - 1;

        System.out.println("请输入要查看的课程编号");

        int scoreIndex = in.nextInt() - 1;

        System.out.println("第" + (year + 1) + "年的" + names[scoreIndex] + "成绩是："
        + scores[year][scoreIndex]);
    }
}
